/*
 * @Author: zhutiantian 2332416811@qq.com
 * @Date: 2025-11-19 17:41:35
 * @LastEditors: zhutiantian 2332416811@qq.com
 * @LastEditTime: 2025-11-19 17:48:50
 * @FilePath: \dingding\src\main\java\com\common\dingding\controller\AuthController.java
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package com.common.dingding.controller;

import com.common.dingding.utils.JwtUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
//import org.apache.shiro.SecurityUtils;
//import org.apache.shiro.authc.UsernamePasswordToken;
//import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/auth")
@Tag(name = "认证管理", description = "用户认证相关接口")
public class AuthController {

    @Autowired
    private JwtUtils jwtUtils;

//    @PostMapping("/login")
//    @Operation(summary = "用户登录", description = "用户登录获取JWT令牌")
//    public Map<String, Object> login(@RequestParam String username, @RequestParam String password) {
//        Subject subject = SecurityUtils.getSubject();
//        UsernamePasswordToken token = new UsernamePasswordToken(username, password);
//
//        try {
//            subject.login(token);
//            String jwt = jwtUtils.generateToken(username);
//            Map<String, Object> result = new HashMap<>();
//            result.put("access_token", jwt);
//            result.put("token_type", "Bearer");
//            return result;
//        } catch (Exception e) {
//            Map<String, Object> result = new HashMap<>();
//            result.put("error", "登录失败：" + e.getMessage());
//            return result;
//        }
//    }

    @RequestMapping("/index")
    public String index() {
        return "登录成功";
    }

    @RequestMapping("/unauthorized")
    public String unauthorized() {
        return "未授权访问";
    }
}